#include "LeftWidget.h"

LeftWidget::LeftWidget(QWidget *parent)
    : QWidget(parent),
      m_layout(new QVBoxLayout(this))
{
    // 设置对象名用于QSS选择
    setObjectName("leftMainContainer");
    
    // 主容器配置
    QWidget *mainWidget = new QWidget();
    mainWidget->setObjectName("leftContentPanel");
    mainWidget->setFixedWidth(300);
    
    m_layout->setContentsMargins(0, 0, 0, 0);
    m_layout->setSpacing(0);
    m_layout->addWidget(mainWidget);

    // 内部布局
    mainWidgetLayout = new QVBoxLayout(mainWidget);
    mainWidgetLayout->setAlignment(Qt::AlignTop);
    mainWidgetLayout->setContentsMargins(8, 8, 8, 8); // 增加内边距
    mainWidgetLayout->setSpacing(12); // 增加控件间距

    // 卫星类型选择框
    typeComboBox = new QComboBox();
    typeComboBox->setObjectName("satelliteComboBox");
    QComboBoxManager::getInstance().setTypeComboBox(typeComboBox);
    typeComboBox->addItems({"BD", "GPS", "Galileo"});
    connect(typeComboBox, &QComboBox::currentTextChanged, 
            this, &LeftWidget::onTypeChanged);

    // 滚动区域
    scrollArea = new QScrollArea();
    scrollArea->setObjectName("satelliteScrollArea");
    QWidget *scrollContent = new QWidget();
    scrollContent->setObjectName("scrollContent");
    scrollArea->setWidget(scrollContent);
    scrollArea->setWidgetResizable(true);

    // 通知区域
    notiArea = new QWidget();
    notiArea->setObjectName("notificationPanel");
    notiArea->setFixedHeight(200);

    // 组装布局
    mainWidgetLayout->addWidget(typeComboBox);
    mainWidgetLayout->addWidget(scrollArea, 1);
    mainWidgetLayout->addWidget(notiArea);

    // 初始化
    onTypeChanged(this->getType());
}